// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    // const logs = wx.getStorageSync('logs') || []
    // logs.unshift(Date.now())
    // wx.setStorageSync('logs', logs)

    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
        if(res.code){
          var code = res.code;
          wx.request({
            url: this.globalData.api + 'applet/user/login',
            data:{
              jsCode: code
            },
            method:'POST',
            success: res => {
              this.globalData.userInfo.UserNo = res.data.data;
              wx.setStorageSync('UserNo', res.data.data);
            }
          })
        }
      }
    })
  },
  globalData: {
    userInfo: {
      UserNo:''
    },
    api: "http://localhost:8848/",
    // api: "https://d622-2409-8a71-846-8a70-b898-b177-a3f6-18c4.ngrok-free.app/",
  },

})
